<template>
<div>
<CityHeader></CityHeader>
<Search :citys=citys></Search>
<List :citys=citys :hotcitys=hotcitys :letter=letter></List>
<zimu :citys=citys @change="handleletterchange"></zimu>
</div>
</template>

<script>
import CityHeader from './components/header'
import Search from './components/search'
import List from './components/list'
import zimu from './components/zimu'
import axios from 'axios'
export default {
  name: 'City',
  data () {
    return {
      citys: {},
      hotcitys: [],
      letter: ''
    }
  },
  components: {
    CityHeader,
    Search,
    List,
    zimu
  },
  mounted () {
    this.getCityInfo()
  },
  methods: {
    getCityInfo () {
      axios.get('/api/city.json')
        .then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.citys = data.cities
        this.hotcitys = data.hotCities
      }
    },
    handleletterchange (letter) {
      // console.log(letter) 父组件接收到zimu组件传来的值
      this.letter = letter
    }
  }
}
</script>

<style >

</style>
